package com.suep.system.utils;
/*
* 生成验证码的工具
* */

import java.util.Random;

public class VerificationCodeUtil {
    private static final String ALLOWED_CHARACTERS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    private static final int CODE_LENGTH = 6;

    /**
     * 生成 6 位随机验证码
     * @return 6 位随机验证码
     */
    public static String generateVerificationCode() {
        Random random = new Random();
        StringBuilder code = new StringBuilder();
        for (int i = 0; i < CODE_LENGTH; i++) {
            int randomIndex = random.nextInt(ALLOWED_CHARACTERS.length());
            code.append(ALLOWED_CHARACTERS.charAt(randomIndex));
        }
        return code.toString();
    }
}
